const jwt = require('koa-jwt');
const Router = require('koa-router');
const router = new Router({prefix:'/topics'});
const {find,findById,create,update,topicFollowers,
      checkTopicExist,listQuestions} = require('../controllers/topics')

const {secret} = require('../config')
//认证
const auth = jwt({secret});

router.get('/',find);
router.post('/',auth,create);
router.get('/:id',checkTopicExist,findById);
router.patch('/:id',auth,checkTopicExist,update);

router.get('/:id/followers',checkTopicExist,topicFollowers);
router.get('/:id/questions',checkTopicExist,listQuestions);  //请求话题的问题列表

module.exports = router;   